package com.shop.mall.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.io.Serializable;

/**
 * @author admin
 * @date 2019/4/30
 * @since 1.0
 */
public class BaseResultVO implements Serializable {

    private Boolean result = true;
    private Integer code = 0;
    private String data;
    private String message = "success";

    public BaseResultVO() {
    }

    public BaseResultVO(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public BaseResultVO(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMessage();
    }

    public void setErrorCode(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMessage();
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

    public Boolean getResult() {
        if (0 != code.intValue()) {
            result = false;
        }
        return result;
    }

    public void setResult(Boolean result) {
        this.result = result;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
